<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
  <style>
    .masonry{
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      /* grid-template-rows: repeat(3, 1fr); 这个可不写，因为会根据数量所变化*/
      grid-auto-rows: auto;/* 设置多余的网格高度 */
      column-gap: 5px;
      font-size: 30px;
    }
    .item:first-child{
      /* grid-row-start: 1;开始于第一行，就是第一根横向网格线
      grid-row-end: 3;结束于第三行，就是第三根横向网格线
      grid-column-start: 2;同上，但是是开始于纵向的网格线
      grid-column-end: 3; */

      grid-row-start: auto;
      grid-row-end: span 10; /* 从第一根横向网格线开始，向下跨两个网格*/
    }
    .item:nth-child(2){
      grid-row-start: auto;
      grid-row-end: span 15;
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="masonry">
      <div class="item" v-for="i in 9" :style="getStyle(i)">{{ i }}</div>
    </div>
  </div>

  <script>
    const { createApp, ref, reactive } = Vue
    createApp({
      setup() {
        const heights = [150, 160, 170, 180, 140, 155, 165, 180, 175]
        const colors = [
          "#ef3429",
          "#f68f25",
          "#4ba846",
          "#0476c2",
          "#c077af",
          "#f8d29d",
          "#b4a87f",
          "#d0e4a8",
          "#4dc7ec"
        ]

        const getStyle = (index) => {
          return {
            height: heights[index - 1] + "px",
            backgroundColor: colors[index - 1]
          }
        }

        return {
          heights,
          colors,
          getStyle
        }
      }
    }).mount('#app')


  </script>  
</body>
</html>